{template 'public/header'}
{template 'public/comhead'}
<style type="text/css">
    .nav-tabs{
        margin-top: 30px;
    }
    .nav-tabs>li>a:hover{
        color: #333;
        border-color: #31C2A5;
        background-color: white;
    }
    .nav-tabs > li.active > a,.nav-tabs > li.active > a:hover{
        background-color: #31C2A5;
        color: white;
        border-color: #31C2A5;
    }
    .nav.nav-tabs{border-color: #31C2A5;}
    .yg5_key>div{float: left;line-height: 34px;}
    .store_td1{height: 45px;}
    .store_list_img{width: 60px;height: 60px;}
    .yg5_tabel{border-color: #e5e5e5;outline: 1px solid #e5e5e5;}
    .yg5_tr2>td{padding: 15px;border: 1px solid #e5e5e5;text-align: center;}
    .yg5_tr1>td{
        border: 1px solid #e5e5e5;
        padding-left: 15px;
        background-color: #FAFAFA;
        font-weight: bold;
        text-align: center;
    }
    .yg5_btn{background-color: #EEEEEE;color: #333;border: 1px solid #E4E4E4;border-radius: 6px;width: 100px;height: 34px;}
</style>
<ul class="nav nav-tabs">    
    <li class="active"><a href="{php echo $this->createWebUrl('area')}">门店区域管理</a></li>
    <li><a href="{php echo $this->createWebUrl('addarea')}">添加门店区域</a></li>
</ul>
<div class="main">
    <div class="panel panel-default">
        <div class="panel-body">
            <a class="btn btn-primary" href="javascript:location.reload()"><i class="fa fa-refresh"></i>刷新</a>
        </div>
    </div>
    <!-- 门店列表部分开始 -->
        <div class="panel panel-default">
            <div class="panel-heading">
                门店区域管理
            </div>
            <div class="panel-body" style="padding: 0px 15px;">
                <div class="row">
                    <table class="yg5_tabel col-md-12">
                        <tr class="yg5_tr1">
                            <td class="store_td1 col-md-1">顺序</td>
                            <td class="col-md-2">区域名称</td>
                            <td class="col-md-3">操作</td>
                        </tr>
                        {loop $list $row}
                        <tr class="yg5_tr2">
                            <td class="num{$row['id']}">
                                <span class="numspan{$row['id']}">{$row['num']}</span>
                                <input style="display: none;width: 100%;" type="number" name="num{$row['id']}" class="numinp{$row['id']}" value="{$row['num']}" />
                                <script type="text/javascript">
                                    $(function(){
                                        $(".num{$row['id']}").each(function(index){
                                             $(this).dblclick(function(){
                                                $(".numinp{$row['id']}").eq(index).show().focus();
                                                $(".numspan{$row['id']}").eq(index).hide();                                         
                                            });
                                        });
                                        $(".numinp{$row['id']}").each(function(index){
                                            $(this).blur(function(){            
                                                $(".numinp{$row['id']}").eq(index).hide();
                                                $(".numspan{$row['id']}").eq(index).show();
                                                var text = $(".numspan{$row['id']}").html();
                                                var inp = $(" input[ name='num{$row['id']}' ] ").val();
                                                $(".numspan{$row['id']}").html(inp);
                                                console.log(inp);
                                                id = {$row['id']};
                                                num = inp;
                                                $.ajax({
                                                    type:"post",
                                                    url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=UpdArea&m=zh_tcwq",
                                                    dataType:"text",
                                                    data:{id:id,num:num},
                                                    success:function(data){
                                                        console.log(data);
                                                    }
                                                })
                                        
                                            });
                                        });
                                    })
                                </script>
                            </td>
                            <td>{$row['area_name']}</td>
                            <td><a class="btn btn-warning btn-sm" href="{php echo $this->createWebUrl('addarea', array('id' => $row['id']))}" title="编辑">改</a>&nbsp;&nbsp;
                           <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#myModal{$row['id']}">删</button>
                            </td>
                        </tr>
                         <div class="modal fade" id="myModal{$row['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                        </div>
                        <div class="modal-body" style="font-size: 20px">
                            确定删除么？
                        </div>
                        <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <a href="{php echo $this->createWebUrl('area', array('id' => $row['id']))}" type="button" class="btn btn-info" >确定</a>
                        </div>
                    </div>
                </div>
            </div>
                        {/loop}
                       
                    </table>
                </div>
            </div>
        </div>
    {$pager}
</div>
<!-- {template 'common/footer'} -->